#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@File ：UserParser.py
@Author ：zqy
@Email : zqingy@work@163.com
@note:
"""

from application.Parser import BaseValidator, JSONRequestParser


class UserValidator(BaseValidator):

    @classmethod
    def put(cls) -> JSONRequestParser:
        p = JSONRequestParser(trim=True)
        # p.add_argument("username", type=str, help="用户名")
        p.add_argument("avatar", type=str, help="头像")
        p.add_argument("email", type=cls.email, help="邮箱")
        p.add_argument("nickname", type=str, help="昵称")
        return p

    @classmethod
    def register(cls) -> JSONRequestParser:
        p = JSONRequestParser(trim=True)
        p.add_argument_required_non_null("phone", type=cls.phone_number, help="手机号码")
        p.add_argument_required_non_null("username", type=str, help="用户名")
        p.add_argument_required_non_null("nickname", type=str, help="昵称")
        p.add_argument_required_non_null("password", type=cls.password, help="密码")
        return p

    @classmethod
    def login(cls) -> JSONRequestParser:
        p = JSONRequestParser(trim=True)
        p.add_argument_required_non_null("username", type=str, help="用户名")
        # p.add_argument_required_non_null("phone", type=str, help="手机号码")
        p.add_argument_required_non_null("password", type=cls.password, help="密码")
        return p

    @classmethod
    def change_avatar(cls) -> JSONRequestParser:
        p = JSONRequestParser(trim=True)
        p.add_argument_required_non_null("avatar_url", type=str, help="头像")
        return p

    @classmethod
    def change_password(cls) -> JSONRequestParser:
        p = JSONRequestParser(trim=True)
        p.add_argument_required_non_null("old_password", type=str, help="旧密码")
        p.add_argument_required_non_null("new_password", type=str, help="新密码")
        return p

    @classmethod
    def change_nickname(cls) -> JSONRequestParser:
        p = JSONRequestParser(trim=True)
        p.add_argument_required_non_null("nickname", type=str, help="昵称")
        return p
